package study.oss测试;

import com.aliyun.oss.ClientBuilderConfiguration;
import com.aliyun.oss.ClientConfiguration;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.common.comm.Protocol;
import com.aliyun.oss.model.ObjectListing;

/**
 * @Author 刘伟涛
 * @Date 2024/6/28 15:45
 **/
public class ConfigureLogging {
    public static void main(String[] args) {
// 设置阿里云OSS访问凭证
        String endpoint = "http://oss-cn-shenzhen.aliyuncs.com";
        String accessKeyId = "LTAI5tLtxS5UW8HR9MFKnb5P";
        String accessKeySecret = "62oVaKMuNerriUZHke1IKHz5VLTzIF";

        // 创建ClientConfiguration实例
        ClientBuilderConfiguration conf = new ClientBuilderConfiguration();
        conf.setProtocol(Protocol.HTTPS);

        // 启用详细日志
        System.setProperty("com.aliyun.oss.loglevel", "debug");

        // 创建OSSClient实例
        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret, conf);

        // 使用OSSClient进行操作...
        ObjectListing objectListing = ossClient.listObjects("lims2-0");
        System.out.println(objectListing);
        // 关闭OSSClient
        ossClient.shutdown();
    }
}
